package com.weiyi.servlet01;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 
 * @description 获取servlet环境信息
 * @author 惟一
 * @date 2020年6月26日下午6:02:10
 */
@WebServlet("/servlet/*")
public class PathDemo extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html;charset=UTF-8");
		PrintWriter out = resp.getWriter();
		
		//requestURI = contextpath + servletPath + pathInfo
		//           =  Servlet用例     /  servlet    / path.view
		out.println("<html>");
		out.println("<head>");
		out.println("<title>Servlet Pattern</title>");
		out.println("</head>");
		out.println("<body>");
		out.println(req.getRequestURI()+"</br>");
		out.println(req.getContextPath()+"</br>");
		out.println(req.getServletPath()+"</br>");
		out.println(req.getPathInfo()+"</br>");
		out.println("</body>");
		out.println("</html>");
		
		out.close();
	}
}
